import {requestResponse} from '~/../config/axios.conf'
import {ciipSerUrl} from '~/../config/server.url.conf'

// 获取当前用户信息
export const getUserInfo = () => requestResponse('get', ciipSerUrl + '/anon/resource/user', null, true)
// 获取当前用户token
export const getVdCode = () => requestResponse('post', ciipSerUrl + '/anon/getLoginQrCodeToken', null, true)

export const getTree = () => requestResponse('get', '/anon/tree')

export const getClassid = (type:string) => {
    const url = type === 'community' ? '/anon/findExpertClassList' : '/anon/tree'
    return requestResponse('get', url)
}
// 友情链接
export const getLinkList = () => requestResponse('get', ciipSerUrl + '/anon/getAllFriendShipLinkList?friendshipServiceKey=CIIP&belongLanguage=CHINESE&pageNumber=1&pageSize=15', null, true)
/**
 * 收藏取消收藏
 *    collectionUserId 当前用户id
 *    collectionSourceId 目标源id
 *    operateType add | del
 *    collectionType   服务 SUPPLY_SERVICE   需求 DEMAND_NEEDS   店铺 CIIP_SHOP
 *    shopType   JYJ BPSC SUPPLY
 *    classId  分类id 无传为空字符
 * */
export const setCollection = (json: any) => requestResponse('post', '/authc/myOperate/collection/addOrDel', json)
/**
 * 验证是否收藏
 *    userId 当前用户id
 *    id 目标源id
 *    collectionType
 *    shopType
 * */
export const validateCollection = (json: any) => requestResponse('post', '/authc/myOperate/collection/findUserIsCollectionBySourceId', json)
// 验证当前用户访问权限
export const validateUserAuthor = (mark: string, uuid: string, menuUrl: string) => requestResponse('get', ciipSerUrl + '/anon/menu/hasSupplyDemandPermission', {mark, uuid, menuUrl}, true)
